package com.joysuch.wwyt.bp.controller;

import com.joysuch.wwyt.bp.bean.BpDeviceFacilityDetectRecordBean;
import com.joysuch.wwyt.bp.service.BpDeviceFacilityDetectRecordService;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 设备装置检测记录
 *
 * @Author ZhangDong
 * @Date 2021/1/12 14:08
 */
@RestController
@RequestMapping("/bp/device-facility-detect-record")
@Api(tags = "设备设施管理-设备检测")
public class BpDeviceFacilityDetectRecordController {

    @Autowired
    private BpDeviceFacilityDetectRecordService service;

    @PostMapping("save")
    @ApiOperation("新增/修改")
    @RequiresPermissions("bp:device-facility-detect-record:save")
    public ResultBean save(@RequestBody @Valid BpDeviceFacilityDetectRecordBean bean) {
        return service.save(bean);
    }

    @GetMapping("page")
    @ApiOperation(value = "基于设备装置id分页查询", response = BpDeviceFacilityDetectRecordBean.class)
    public ResultBean page(Pageable pageable, Long deviceFacilityId) {
        return service.page(pageable, deviceFacilityId);
    }

    @GetMapping("getById")
    @ApiOperation("检测记录单体查询")
    public ResultBean getById(Long id) {
        return service.getById(id);
    }

    @GetMapping("/deleteById")
    @ApiOperation(value = "删除记录")
    public ResultBean deleteById(Long recordId) {
        service.deleteById(recordId);
        return ResultBean.success("");
    }
}
